package org.example.device.kafka.consume;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.example.device.kafka.event.DeviceNotifyKafkaEvent;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@ConditionalOnProperty(prefix = "spring.kafka", name = "enable", havingValue = "true")
public class DeviceConsumer {
    @KafkaListener(topics = {"kafka-test"}, containerFactory = "batchCustomerContainerFactory")
    public void consumerListener(DeviceNotifyKafkaEvent message, Acknowledgment ack) {
        log.info("msg：{}", JSON.toJSONString(message));
        ack.acknowledge();
    }
}
